package org.luxor.cloud.gateway.controller;

import org.luxor.cloud.gateway.service.DynamicRouteService;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 内部身份安全认证接口
 *
 * @author Mr.Yan  @date: 2020/9/8
 */
@RestController
public class DefaultController {

    @Resource
    private DynamicRouteService dynamicRouteService;

    @GetMapping("/")
    public String index() {
        return "index";
    }

    @GetMapping("/error")
    public String error() {
        return "error/error";
    }

    @GetMapping("/info")
    public String test() {
        return "欢迎使用《luxor-cloud 微服务API接入网关》";
    }

    @GetMapping("/routes")
    public Map<String, RouteDefinition> routes() {
        return dynamicRouteService.routeDefinitions();
    }

}
